package me.zhengjie.modules.rest.enterprise;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.modules.domain.enterprise.EnterpriseProduct;
import me.zhengjie.modules.service.EnterpriseProductService;
import me.zhengjie.modules.utils.Contents;
import me.zhengjie.modules.utils.JsonUtils;
import me.zhengjie.modules.utils.ReturnObject;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api("企业竟品信息APi")
@RestController
@RequiredArgsConstructor
@RequestMapping("/enterPro")
public class EnterpriseProductController {

    private final EnterpriseProductService enterpriseProductService;

    @AnonymousAccess
    @ApiOperation("根据企业名称分页查询竟品信息")
    @GetMapping("/queryEnterpriseProForPageByName")
    public Map<String,Object> queryEnterpriseProForPageByName(String name,@RequestParam("pageNo") Integer pageNo,@RequestParam("pageSize") Integer pageSize){
        Map<String, Object> map=new HashMap<>();
        map.put("name",name);
        map.put("pageNo",(pageNo-1)*pageSize);
        map.put("pageSize",pageSize);
        List<EnterpriseProduct> list=enterpriseProductService.queryEnterpriseProForPageByName(map);
        int total=enterpriseProductService.queryEnterpriseProForTotalByName(map);
        map=new HashMap<>();
        map.put("list",list);
        map.put("total",total);
        return map;
    }
}
